package com.richapp.launcher.database.system.dao;

import java.util.ArrayList;
import java.util.List;
import com.j256.ormlite.stmt.DeleteBuilder;
import com.richapp.launcher.database.system.SystemBaseDao;
import com.richapp.launcher.database.system.mode.ConditionSensorModel;

import android.content.Context;
import android.util.Log;

public class ConditionSensorModelDao extends SystemBaseDao<ConditionSensorModel>{

	public ConditionSensorModelDao(Context context) {
		super(context,ConditionSensorModel.class);
	}
	
	public List<ConditionSensorModel> getList(String sceneName){
		List<ConditionSensorModel> list = new ArrayList<ConditionSensorModel>();
		try {
			list = gettOp().queryBuilder().where().eq("sceneName", sceneName).query();
		} catch (Exception e) {
			Log.e(getClass().getName(), e.getMessage());
		}
		return list;
	}
	
	public void del(String sceneName){
		try {
			DeleteBuilder<ConditionSensorModel, Integer> deleteBuilder = gettOp().deleteBuilder();
			deleteBuilder.where().eq("sceneName", sceneName);
			deleteBuilder.delete();
		} catch (Exception e) {
			Log.e(getClass().getName(), e.getMessage());
		}
	}


	public ConditionSensorModel getConditionSensorModel(String sceneName){
		ConditionSensorModel conditionSensorModel = null;
		try {
			conditionSensorModel = gettOp().queryBuilder().where().eq("sceneName", sceneName).queryForFirst();
		} catch (Exception e) {
			Log.e(getClass().getName(), e.getMessage());
		}
		return conditionSensorModel;
	}
}
